-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enclosing package p.q not visible as q #23069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fca2ca4
to
05fc3cd
Compare
It's been a while since I ran the lint on the dotty code base. |
05fc3cd
to
bea7edc
Compare
@@ -419,7 +419,7 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha | |||
candidate = cur | |||
importer = sel | |||
else if checkMember(cur.owner) then | |||
if sym.srcPos.sourcePos.source == ctx.source then | |||
if sym.is(Package) || sym.srcPos.sourcePos.source == ctx.source then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package sym has no source to compare.
bea7edc
to
06d1611
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Do you want to keep the 3 commits? From the looks of it, the whole diff is a lot smaller than the individual commits.
06d1611
to
e392382
Compare
I need one commit for my semester project, another for my master's, and the last for the published paper. |
Fixes #23047
Normally, an enclosing definition always has higher "name binding" precedence than an import, but an enclosing packaging can have a dotted name with a simple name that can't be referenced without qualification or import.
This first cut gives up, but we can infer whether a package was introduced with a dotted name by comparing the owner of the current context with the enclosing package owner.
The second commit does that clever thing (which is not necessarily a good thing).
The final cut just relies on "finding the p.q in an enclosing context", just like any definition. An actual definition may have a position in a different file (which is lower precedence); but an enclosing definition or an enclosing package clause which is unpositioned can only be in the current file.